package com.xianyun.site.support.executor.handle.sms.v20201114.config;

import com.xianyun.site.support.executor.handle.sms.BaseSmsStrategy;
import com.xianyun.site.support.executor.handle.sms.v20201114.impl.IBaseSmsCheckStrategyImpl;
import com.xianyun.site.support.executor.handle.sms.v20201114.impl.IBaseSmsResultStrategyImpl;

/**
 * 短信发送类型
 * @author mac_zyj
 */

public enum SmsSendStrategyType {
    /**校验策略*/
    CHECK_TYPE("校验","1", new IBaseSmsCheckStrategyImpl()),
    /**结果策略*/
    RESULT_TYPE("结果","2",new IBaseSmsResultStrategyImpl()),
    /**推送策略*/
    PUSH_TYPE("推送","3",null),
    /**默认策略*/
    OTHER("其他","4",null);
    /**类型名称*/
    private final String typeName;
    /**类型*/
    private final String type;
    /**策略*/
    private final BaseSmsStrategy baseSmsStrategy;

    SmsSendStrategyType(String typeName, String type, BaseSmsStrategy baseSmsStrategy) {
        this.typeName = typeName;
        this.type = type;
        this.baseSmsStrategy = baseSmsStrategy;
    }

    public BaseSmsStrategy getSmtpStrategy() {
        return baseSmsStrategy;
    }

    public static Class<? extends  BaseSmsStrategy> getSmsStrategyByType(String type){
        for (SmsSendStrategyType sendType:values()){
            if (sendType.type.equals(type)){
                return sendType.getSmtpStrategy().getClass();
            }
        }
        return null;
    }

    public static String getSmsTypeNameByType(String type){
        for (SmsSendStrategyType sendType:values()){
            if (sendType.type.equals(type)){
                return sendType.typeName;
            }
        }
        return null;
    }
}
